<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Electron 双窗口示例</title>
  <style>
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    }
    
    body {
      background: linear-gradient(135deg, #1e3c72, #2a5298);
      color: white;
      min-height: 100vh;
      display: flex;
      flex-direction: column;
      align-items: center;
      padding: 2rem;
      text-align: center;
    }
    
    .header {
      margin-bottom: 2rem;
      text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    }
    
    h1 {
      font-size: 2.5rem;
      margin-bottom: 0.5rem;
    }
    
    .subtitle {
      font-size: 1.2rem;
      opacity: 0.9;
      max-width: 600px;
    }
    
    .card-container {
      display: flex;
      justify-content: center;
      flex-wrap: wrap;
      gap: 2rem;
      margin: 2rem 0;
      max-width: 1200px;
    }
    
    .card {
      background: rgba(255, 255, 255, 0.1);
      border-radius: 20px;
      padding: 2rem;
      width: 300px;
      backdrop-filter: blur(10px);
      border: 1px solid rgba(255,255,255,0.2);
      box-shadow: 0 10px 30px rgba(0,0,0,0.3);
      transition: transform 0.3s ease;
    }
    
    .card:hover {
      transform: translateY(-10px);
    }
    
    .card-title {
      font-size: 1.5rem;
      margin-bottom: 1rem;
      color: #4fc3f7;
    }
    
    .card-content {
      font-size: 1rem;
      line-height: 1.6;
      margin-bottom: 1.5rem;
      color: #e0f7fa;
    }
    
    .card-icon {
      font-size: 3rem;
      margin-bottom: 1rem;
      color: #4fc3f7;
    }
    
    .btn-container {
      margin: 3rem 0;
    }
    
    .create-btn {
      background: linear-gradient(to right, #43cea2, #185a9d);
      border: none;
      color: white;
      padding: 1.2rem 3rem;
      font-size: 1.2rem;
      font-weight: bold;
      border-radius: 50px;
      cursor: pointer;
      box-shadow: 0 5px 15px rgba(0,0,0,0.3);
      transition: all 0.3s ease;
      outline: none;
      position: relative;
      overflow: hidden;
    }
    
    .create-btn:hover {
      transform: scale(1.05);
      box-shadow: 0 8px 20px rgba(0,0,0,0.4);
    }
    
    .create-btn:active {
      transform: scale(0.98);
    }
    
    .create-btn::after {
      content: '';
      position: absolute;
      top: -50%;
      left: -50%;
      width: 200%;
      height: 200%;
      background: rgba(255,255,255,0.1);
      transform: rotate(30deg);
      transition: all 0.6s ease;
    }
    
    .create-btn:hover::after {
      transform: rotate(30deg) translate(20%, 20%);
    }
    
    .status {
      margin-top: 2rem;
      padding: 1rem;
      background: rgba(0,0,0,0.2);
      border-radius: 10px;
      min-width: 300px;
    }
    
    .window-status {
      display: flex;
      justify-content: center;
      gap: 2rem;
      margin-top: 1rem;
    }
    
    .status-item {
      display: flex;
      align-items: center;
      gap: 0.5rem;
    }
    
    .status-indicator {
      width: 12px;
      height: 12px;
      border-radius: 50%;
      display: inline-block;
    }
    
    .open {
      background-color: #4caf50;
      box-shadow: 0 0 10px #4caf50;
    }
    
    .closed {
      background-color: #f44336;
    }
    
    footer {
      margin-top: auto;
      padding: 1rem;
      font-size: 0.9rem;
      opacity: 0.7;
    }
  </style>
</head>
<body>
  <div class="header">
    <h1>Electron 双窗口示例</h1>
    <p class="subtitle">点击下方按钮创建两个新窗口：一个打开开发者工具，另一个保持普通状态</p>
  </div>
  
  <div class="card-container">
    <div class="card">
      <div class="card-icon">🔧</div>
      <h2 class="card-title">调试窗口</h2>
      <p class="card-content">此窗口将自动打开开发者工具，用于调试和检查应用程序。开发者工具将以分离模式打开，可以自由移动。</p>
    </div>
    
    <div class="card">
      <div class="card-icon">📋</div>
      <h2 class="card-title">普通窗口</h2>
      <p class="card-content">此窗口保持标准状态，不自动打开开发者工具。您可以通过右键菜单手动打开开发者工具。</p>
    </div>
    
    <div class="card">
      <div class="card-icon">⚙️</div>
      <h2 class="card-title">窗口管理</h2>
      <p class="card-content">所有窗口独立管理，关闭主窗口不会影响已创建的子窗口。应用程序在所有窗口关闭后退出。</p>
    </div>
  </div>
  
  <div class="btn-container">
    <button id="create-btn" class="create-btn">创建两个新窗口</button>
  </div>
  
  <div class="status">
    <h3>窗口状态</h3>
    <div class="window-status">
      <div class="status-item">
        <span class="status-indicator closed" id="devtools-status"></span>
        <span>调试窗口</span>
      </div>
      <div class="status-item">
        <span class="status-indicator closed" id="normal-status"></span>
        <span>普通窗口</span>
      </div>
    </div>
  </div>
  
  <footer>
    Electron 多窗口示例 | 按 F12 打开当前窗口的开发者工具
  </footer>
  
  <script>
    const createBtn = document.getElementById('create-btn');
    const devtoolsStatus = document.getElementById('devtools-status');
    const normalStatus = document.getElementById('normal-status');
    
    createBtn.addEventListener('click', async () => {
      try {
        createBtn.disabled = true;
        createBtn.textContent = '创建中...';
        
        const result = await window.electronAPI.createWindows();
        
        if (result.devToolsWindow) {
          devtoolsStatus.className = 'status-indicator open';
        }
        
        if (result.normalWindow) {
          normalStatus.className = 'status-indicator open';
        }
        
        setTimeout(() => {
          createBtn.disabled = false;
          createBtn.textContent = '创建两个新窗口';
        }, 2000);
        
      } catch (err) {
        console.error('创建窗口失败:', err);
        alert(`创建窗口时出错: ${err.message}`);
        createBtn.disabled = false;
        createBtn.textContent = '创建两个新窗口';
      }
    });
    
    // 当前窗口开发者工具快捷键
    document.addEventListener('keydown', (e) => {
      if (e.key === 'F12') {
        window.electronAPI.openDevTools();
      }
    });
  </script>
</body>
</html>